import {Injectable} from "@angular/core";

export class Role {
    constructor(public id:number, public name:string) {
    }
}

let ROLES = [
    new Role(11, 'Mr. Nice'),
    new Role(12, 'Narco'),
    new Role(13, 'Bombasto'),
    new Role(14, 'Celeritas'),
    new Role(15, 'Magneta'),
    new Role(16, 'RubberMan')
]

let rolePromise = Promise.resolve(ROLES);

@Injectable()
export class RoleService {


    getRoles() {
        return rolePromise;
    }

    getRole(id:number | string) {
        return rolePromise.then(roles=>roles.find(role=>role.id === +id));
    }


}